package com.shop2cn.iapi.agentproducts.service;

import com.google.common.reflect.TypeToken;
import com.shop2cn.iapi.agentproducts.parameter.OpenProductDto;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;

import java.util.List;

/**
*获取商户商品列表Call
*FreeMaker Template自动生成代码
*/
public class QueryProductListCall extends YmatouBaseCall{
	private static String opurl ="open/queryProductList";
	
	public QueryProductListCall() {
		super(EnvSetup.getSystemUrl("agentproducts_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	public List<OpenProductDto> getProductList(){
		String sResults=getJsonObject().get("data").getAsJsonObject().get("productInfoList").getAsJsonArray().toString();
		List<OpenProductDto> FreezeProductResultList=(List<OpenProductDto>) FormatUtil.GSONToObject(sResults, new TypeToken<List<OpenProductDto>>(){}.getType());
		return FreezeProductResultList;
	}

}